package com.example.controller;

import com.example.pojo.Comments;
import com.example.pojo.Result;
import com.example.service.CommentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/comments")
public class CommentsController {

    @Autowired
    private CommentsService commentsService;

    @GetMapping
    public Result<List<Comments>> list(
            @RequestParam(required = false) Integer goodsId,
            @RequestParam(required = false) Integer stuId
    ) {
        List<Comments> commentsList = commentsService.list(goodsId, stuId);
        return Result.success(commentsList);
    }
}